package cn.xshi.gateway.route.client.core;

import com.alibaba.fastjson.JSONObject;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import cn.xshi.gateway.route.client.vo.ChannelEntity;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
 * @Desc 解码器（自定义Json解码器）
 * @Author 邓纯杰
 * @CreateTime 2021-09-18
 */
@Slf4j
public class JsonMessageDecoder extends MessageToMessageDecoder<String> {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, String str, List<Object> list) throws Exception {
        ChannelEntity channelEntity = JSONObject.parseObject(str, ChannelEntity.class);
        log.info("收到报文："+JSONObject.toJSONString(str));
        list.add(channelEntity);
    }
}
